package com.test.controller;

import com.test.entity.Adminuser;
import com.test.service.AdminuserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/admin/info")
public class AdminuserInfoCtrl {

    @Autowired
    private AdminuserService adminuserService;


    @GetMapping("getinfo")
    public String getinfo(HttpServletRequest request, Model model) {
        Object loginUser = request.getSession().getAttribute("aduName");
        Object aduPassword = request.getSession().getAttribute("aduPassword");
        Adminuser adminuser = new Adminuser();
        adminuser.setName(loginUser.toString());
        adminuser.setPassword(aduPassword.toString());
        adminuser = adminuserService.getUserInfo(adminuser);

        model.addAttribute("adminuser", adminuser);
        return "userinfo";
    }

}
